﻿<phone:PhoneApplicationPage
    x:Class="SmarterCharger.App.Views.StartChargingBatteryPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:converters="clr-namespace:SmarterCharger.App.Converters"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">
    
    <phone:PhoneApplicationPage.Resources>
        <converters:IsChargingToButtonTextConverter x:Key="IsChargingToButtonTextConverter"/>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,12">
            <Image Source="../Assets/Logo.png" Height="159" Margin="12, 0, 0, 24" HorizontalAlignment="Left" />
            <TextBlock Text="{Binding Path=LocalizedResources.Title_StartCharging, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextTitle2Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>

            <ProgressBar IsIndeterminate="True" Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>

            <ScrollViewer x:Name="scroller" Grid.Row="1" Template="{StaticResource ScrollViewerWithIndication}">
                <StackPanel>
                    <TextBlock x:Name="Instructions" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap">
                        <Bold>Plug</Bold> your phone <Bold>charger</Bold> into the <Bold>smart plug</Bold> shown below and tap <Bold>Charge</Bold>
                    </TextBlock>

                    <StackPanel x:Name="SmartPlug" Margin="0,30,0,0">
                        <TextBlock Text="{Binding Path=LocalizedResources.Label_ChoosePlug, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                        <TextBlock Text="{Binding DefaultSmartPlug.Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}" />
                    </StackPanel>
                    <StackPanel x:Name="ChargeLimit" Margin="0,30,0,0">
                        <TextBlock Text="{Binding Path=LocalizedResources.Label_ChargeLimit, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Margin="12,0,0,0" Text="{Binding ChargeLimit}" Style="{StaticResource PhoneTextLargeStyle}" />
                            <TextBlock Margin="0" Style="{StaticResource PhoneTextLargeStyle}">%</TextBlock>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Margin="0,30,0,0">
                        <Button x:Name="Charge" 
                                Width="275"
                                IsEnabled="{Binding IsCharging, Converter={StaticResource BooleanNegationConverter}}"
                                HorizontalAlignment="Left"
                                Command="{Binding ChargeCommand}"
                                Content="{Binding IsCharging, Converter={StaticResource IsChargingToButtonTextConverter}}" />
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized">
            <shell:ApplicationBarIconButton IconUri="/Assets/Edit.png" Text="Settings" Click="Edit" />
            <shell:ApplicationBarIconButton IconUri="/Assets/Cancel.png" Text="Cancel" Click="Cancel" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="About" Click="ApplicationBarMenuItem_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>